package com.cool.modules.base.dto.sys;

import cn.hutool.core.collection.CollectionUtil;
import com.cool.modules.base.entity.sys.BaseSysMenuEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 系统菜单 dto
 * @author todd
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseSysMenuDto {

    private String name;

    private String router;

    private String perms;

    private Integer type;

    private String icon;

    private Integer orderNum;

    private String viewPath;

    private Boolean keepAlive;

    private Boolean isShow;

    private List<BaseSysMenuDto> childMenus;

    public BaseSysMenuDto(BaseSysMenuEntity menu) {
        this.name = menu.getName();
        this.router = menu.getRouter();
        this.perms = menu.getPerms();
        this.type = menu.getType();
        this.icon = menu.getIcon();
        this.orderNum = menu.getOrderNum();
        this.viewPath = menu.getViewPath();
        this.keepAlive = menu.getKeepAlive();
        this.isShow = menu.getIsShow();
        this.childMenus = CollectionUtil.isNotEmpty(menu.getChildMenus())?menu.getChildMenus().stream().map(BaseSysMenuDto::new).toList():new ArrayList<>();
    }

}
